package demo1230.董文祥;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;

public class Person {
    public static void main(String[] args) {
        try (Socket socket = new Socket("127.0.0.1", 8888)) {
            OutputStream os = socket.getOutputStream();
            os.write("一壶清酒,一生沉醉".getBytes());
            os.write("一念来回,度余生无悔".getBytes());


            InputStream is = socket.getInputStream();
            byte[] bs =new byte[1024];
            int read = is.read();
            System.out.println(new String(bs,0,read));
        } catch (UnknownHostException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
